<table id="datagrid_${action_id}" ></table>
<div id="datagrid_${action_id}_tb" style="padding:5px;height:auto">
	<div>
		<input class="easyui-searchbox" data-options="prompt:'Please Input Value',menu:'#datagrid_${action_id}_tb_searcher',searcher:function(v,n){
			var queryParams = {};
			queryParams[n] = v;
			
			var oldpq = $('#datagrid_${action_id}').datagrid('options').queryParams;
			queryParams['_searcher_eq_type#id'] = oldpq['_searcher_eq_type#id'];
			
			$('#datagrid_${action_id}').datagrid('options').queryParams = queryParams;
			$('#datagrid_${action_id}').datagrid('reload');
		}" style="width:300px"></input>
		<div id="datagrid_${action_id}_tb_searcher" style="width:120px">
			<div name="_searcher_lky_realname" data-options="name:'_searcher_lky_realname'">${action.getDatagridTitle('realname')}</div>
			<div name="_searcher_lky_mobile" data-options="name:'_searcher_lky_mobile'">${action.getDatagridTitle('mobile')}</div>
		</div>
	</div>
</div>
<script type="text/javascript">

$(function(){

	$('#datagrid_${action_id}').datagrid({
		iconCls:'icon-save',
		width:'auto',
		height:'auto',
		nowrap: false,
		fit:true,
		fitColumns:true,
		striped: true,
		url:'${request.contextPath}${namespace?default('')}/mp/sso/member-datagrid.json?ajax=true',
		<#if type?has_content>
		queryParams:{'_searcher_eq_type#id':'type?default('')'},
		</#if>
		sortName: 'lastLoginTime',
		sortOrder: 'desc',
		remoteSort: true,
		singleSelect : true,
		idField:'id',
		onBeforeLoad:function(){$('#datagrid_${action_id}').datagrid('unselectAll');},
		columns:[[
					{field:'id',title:'${action.getDatagridTitle('id')}',width:80,align:'center'},
					{field:'mobile',title:'${action.getDatagridTitle('mobile')}',width:80,align:'center'},
					{field:'realname',title:'${action.getDatagridTitle('realname')}',width:80,align:'center'},
					{field:'type',title:'${action.getDatagridTitle('type')}',width:80,align:'center',formatter:function(val,rec){
						<#list types as type>
							if(val.id=='${type.id}'){
								return '${type.title}';
							}
						</#list>
					}},
					{field:'state',title:'${action.getDatagridTitle('state')}',width:80,align:'center',formatter:function(val,rec){
						<#list states as st>
						if(${st.state}==val){
							return '${action.getDatagridTitle('state.'+st.name())}';
						}
						</#list>
					}},
					{field:'gmtCreate',title:'${action.getDatagridTitle('gmtCreate')}',width:80,align:'center',sortable:true},
					{field:'lastLoginTime',title:'${action.getDatagridTitle('lastLoginTime')}',width:80,align:'center',sortable:true},
					{field:'lastLoginIp',title:'${action.getDatagridTitle('lastLoginIp')}',width:80,align:'center'}
				]],
		pagination:true,
		rownumbers:true,
		onDblClickRow:function(idx,data){if(typeof onDblClickRow_${action_id} != 'undefined'){onDblClickRow_${action_id}(idx,data)}},
		onClickRow:function(idx,data){if(typeof onClickRow_${action_id} != 'undefined'){onClickRow_${action_id}(idx,data)}},
		onRowContextMenu:function(e,idx,data){if(typeof onRowContextMenu_${action_id} != 'undefined'){$(this).datagrid('selectRow', idx);onRowContextMenu_${action_id}(e,idx,data)}},
		toolbar:'#datagrid_${action_id}_tb'
	});

});

function sso_member_edit(id){

	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/sso/member-edit.htm?action_id=${action_id}&id='+id,
		width:500,   
		height:500,   
		modal : true,
		title : '${action.getText('form.edit.title')}',
		buttons : [ {
			text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#form_${action_id}').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/sso/member-update.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						d.dialog('destroy');
						$("#datagrid_${action_id}").datagrid('reload');
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		}
		/*,
		onLoad : function() {
			$.get('${request.contextPath}${namespace?default('')}/mp/sso/member-load.json?id='+id+'&n='+Math.random(),{},function(json){
				$('#form_${action_id}').form('load', json);
			},'json');
		}*/
	});
	
}


function sso_member_delete(id){
	$.messager.confirm('${action.getText('bg.message.info')}', '${action.getText('bg.datagrid.delete.ask')}', function(b) {
		if (b) {
			$.ajax({
				url : '${request.contextPath}${namespace?default('')}/mp/sso/member-delete.json',
				data:{deletes : id},
				dataType : 'JSON',
				success : function(json) {
					$.messager.alert(json.title,json.msg,json.level);
					$("#datagrid_${action_id}").datagrid('reload');
					$('#datagrid_${action_id}').datagrid('clearSelections');
				}
			});
		}
	});
}

function sso_member_extra(id){
	$('<div/>').dialog({
		href:'${request.contextPath}${namespace?default('')}/mp/sso/member-extra.htm?ajax=true&id='+id,
		width:500,   
		height:500,   
		title: '${action.getText('form.extra.title')}',
		modal:true,
		maximizable:false,
		collapsible:false,
		minimizable:false,
		resizable:false,
		onClose : function() {
			$(this).dialog('destroy');
		}
	});
}


function sso_member_alter_currency_${action_id}(cur,id){
	$('<div>').dialog({
		href : '${request.contextPath}${namespace?default('')}/mp/sso/member-alter.htm?action_id=${action_id}&key='+cur+'&id='+id,
		width:500,   
		height:500,   
		modal : true,
		title : '${action.getText('currency.change.btn')}',
		buttons : [ {
			text : '${action.getProperty('net.esj.background.message','bg.datagrid.edit')}',
			iconCls : 'icon-edit',
			handler : function() {
				var d = $(this).closest('.window-body');
				$('#sso_currency_alter_form_${action_id}').form('submit', {
					url : '${request.contextPath}${namespace?default('')}/mp/sso/member-doAlter.json',
					onSubmit: function(){
						return $(this).form('validate');
    				},
					success : function(json) {
						eval("json="+json);
						$.messager.alert(json.title,json.msg,json.level);
						if(json.level!='error'){
							d.dialog('destroy');
							$("#datagrid_${action_id}").datagrid('reload');
						}
					}
				});
			}
		} ],
		onClose : function() {
			$(this).dialog('destroy');
		}
	});
}
</script>